home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 316 / libsrc / alrm_nas.s < prev    next >
Encoding:
Text File  |  1988-10-20  |  1.7 KB  |  63 lines

  1. |
  2. |        Cross Development System for Atari ST 
  3. |      Copyright (c) 1988, Memorial University of Newfoundland
  4. |
  5. |   At this point we take over from dos - we know (think?) that the stack
  6. | looks like this now:
  7. |    0    long    pc
  8. |    4    long    arg (pointer to d7 below)
  9. |        (stuff - unknown size - depends on compiler - could be size 0)
  10. |        long    pc
  11. |    *4    long    d7
  12. |    *4+0x4    long    a0
  13. |    *4+0x8    long    d0
  14. |    *4+0xc    long    d1
  15. |        .
  16. |        .
  17. |    *4+0x24    long    d7
  18. |    *4+0x28    long    a0
  19. |        .
  20. |        .
  21. |    *4+0x40    long    a6
  22. |    *4+0x44    word    sr    status register from exception
  23. |    *4+0x46    long    pc    pc from exception
  24. |        stuff
  25. |  The stratagy at this point consists of saving the exception sr/pc and puting
  26. | out own address in place of the pc.  When the system does it's rte we get
  27. | called and we call do_signal (which can call some routine which can do a 
  28. | longjmp).  If do_signal returns then we restore the sr/pc and do a rte.
  29. |
  30. | $Header: alrm_nasty.s,v 1.1 88/02/03 22:37:55 m68k Exp $
  31. |
  32. | $Log:    alrm_nasty.s,v $
  33. | Revision 1.1  88/02/03  22:37:55  m68k
  34. | Initial revision
  35.  
  36. .globl    __in_trap            | extern
  37. .globl    __do_signal            | extern
  38. .globl    __alrm_nasty
  39.  
  40. .comm    __in_trap, 1
  41.  
  42. .comm    alrm_sr, 2            | static
  43. .comm    alrm_pc, 4            | static
  44.  
  45. __alrm_nasty:
  46.     movel    sp@(0x4), a0
  47.     movew    a0@(0x44), alrm_sr
  48.     movel    a0@(0x46), alrm_pc
  49.     movew    #0x2300, a0@(0x44)    | fake sr (with super bit on)
  50.     movel    #alrm_fake, a0@(0x46)    | our fake return routine
  51.     rts
  52.  
  53. alrm_fake:
  54.     moveml    d0-d2/a0-a2, sp@-    | save registers
  55.     movel    #0x1, sp@-        | _do_signal(SIGALRM)
  56.     jsr    __do_signal        |
  57.     addql    #0x4, sp        | pop signum
  58.     moveml    sp@+, d0-d2/a0-a2    | pop registers
  59.     movel    alrm_pc, sp@-        | push the original sr/pc on stack
  60.     movew    alrm_sr, sp@-
  61.     rte
  62.